package it.unibo.deis.lia.mmhc.sfm;

//messaggio restituito da un hop che possiede il servizio cercato
import java.util.Vector;

public class FindedService extends MessageObject {

	private Vector<String> hopGoSequence;
	private int hopGoNumber;
	private Vector<String> hopBackSequence;
	private int hopBackNumber;

	public FindedService(int hopToLive, Object ogg) {
		super(hopToLive, ogg);
		hopGoSequence = new Vector<String>();
		hopBackSequence = new Vector<String>();
	}

	public FindedService(int hopToLive, Object ogg,
			Vector<String> hopGoSequence, Vector<String> hopBackSequence) {
		super(hopToLive, ogg);
		this.hopGoSequence = hopGoSequence;
		hopGoNumber = 0;
		hopBackNumber = 0;
		this.hopBackSequence = hopBackSequence;
	}

	public Vector<String> getHopGoSequence() {
		return hopGoSequence;
	}

	public void setHopGoSequence(Vector<String> hopGoSequence) {
		this.hopGoSequence = hopGoSequence;
	}

	public int getHopGoNumber() {
		return hopBackNumber;
	}

	public void setHopGoNumber(int hopGoNumber) {
		this.hopBackNumber = hopGoNumber;
	}

	public Vector<String> getHopBackSequence() {
		return hopBackSequence;
	}

	public void setHopBackSequence(Vector<String> hopBackSequence) {
		this.hopBackSequence = hopBackSequence;
	}

	public void addGoHop(String nextGo) {
		hopGoSequence.add(nextGo);
	}

	public void addBackHop(String nextBack) {
		hopBackSequence.add(nextBack);
	}

	public String nextBackHop() {
		String hop = hopBackSequence.elementAt(hopBackNumber);
		hopBackNumber++;
		hopGoNumber--;
		return hop;
	}

	public String nextGoHop() {
		String hop = hopGoSequence.elementAt(hopGoNumber);
		hopBackNumber--;
		hopGoNumber++;
		return hop;
	}

	public int getHopBackNumber() {
		return hopBackNumber;
	}

	public void setHopBackNumber(int hopBackNumber) {
		this.hopBackNumber = hopBackNumber;
	}
}
